/**********************************************************************************************/
/* FBL_Util_PathA.cpp	 	                                               					  */
/*                                                                       					  */
/* Copyright Paradigma, 1993-2006                                        					  */
/* All Rights Reserved.                                                 					  */
/**********************************************************************************************/

#include <VShared/FBL/publ/Headers/StdAfx.h>

#include <VShared/FBL/publ/Utilities/FBL_Util_PathA.h>

 
/**********************************************************************************************/
FBL_Begin_Namespace


/**********************************************************************************************/
const char* ExtractNameFromFullPath( const char* inFullPath )
{
	char* p = NULL;

	if( inFullPath )
		p = (char*) strrchr( inFullPath, PATH_DELIMITER );
		
	return p ? (p + 1) : inFullPath;
}


/**********************************************************************************************/
void ExtractDirectoryFromPath( const char inPath[], char* outDir )
{
	const char* pAppName = ExtractNameFromFullPath( inPath );	
	size_t len = pAppName - inPath;
	strncpy(outDir, inPath, len);
	outDir[len] = '\0';
}


/**********************************************************************************************/
const char* ExtractExtFromFileName( const char* inNameWithExt )
{
	if( const char* p = strstr(inNameWithExt, ".") )
		return p + 1;
	else
		return inNameWithExt;
}


/**********************************************************************************************/
char* ExtractBaseFromFileName( const char* inFileName, char* outBase )
{
	if( const char* p = strstr(inFileName, ".") )
	{
		int len = static_cast<int>(p - inFileName);
		strncpy(outBase, inFileName, len);
		outBase[len] = '\0';
		
		return outBase;
	}
	else
	{
		return NULL;
	}
}


/**********************************************************************************************/
FBL_End_Namespace
